<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    {include file="public/static" /}
</head>
<body>

{include file="public/nav" /}

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body ">
                    <form class="layui-form layui-col-space5" >
                        <div class="layui-inline layui-show-xs-block">
                            <input class="layui-input" autocomplete="off" placeholder="内容" value="{$Request.param.content}" name="content" id="content">
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <input class="layui-input" lay-verify="start" autocomplete="off" placeholder="开始日期" value="{$Request.param.start}" name="start" id="start">
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <input class="layui-input" lay-verify="end" autocomplete="off" placeholder="截止日期" value="{$Request.param.end}" name="end" id="end">
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <button class="layui-btn"  lay-submit="" lay-filter="search"><i class="layui-icon">&#xe615;</i>搜索</button>
                            <a href="{:url('Log/logList')}">
                                <button type="button" class="layui-btn"><i class="layui-icon">&#xe639;</i>清空</button>
                            </a>
                        </div>
                    </form>
                </div>
                <div class="layui-card-header">
                    {eq name="check.LoglogExport" value="1"}
                        <button class="layui-btn" onclick="dataExport()">
                            <i class="layui-icon">&#xe67d;</i>日志导出
                        </button>
                    {/eq}
                    {eq name="check.LoglogDelAll" value="1"}
                        <button class="layui-btn layui-btn-danger" onclick="dataDelAll()">
                            <i class="layui-icon">&#xe640;</i>批量删除
                        </button>
                    {/eq}
                </div>
                <div class="layui-card-body layui-table-body">
                    <table class="layui-table layui-form">
                        <thead>
                        <tr>
                            <th>
                                <input type="checkbox" lay-filter="checkbox" name="id" value="" lay-skin="primary">
                            </th>
                            <th>管理员</th>
                            <th>内容</th>
                            <th>IP地址</th>
                            <th>IP</th>
                            <th>时间</th>
                        </thead>
                        <tbody>
                            {volist name="info" id="vo"}
                                <tr>
                                    <td>
                                        <input type="checkbox" name="id[]" value="{$vo.lo_id}" lay-skin="primary">
                                    </td>
                                    <td>{$vo.admin.ad_name}</td>
                                    <td>{$vo.lo_content}</td>
                                    <td>{$vo.lo_address}</td>
                                    <td>{$vo.lo_ip}</td>
                                    <td>{$vo.lo_time|date='Y-m-d H:i:s'}</td>
                                </tr>
                            {/volist}
                        </tbody>
                    </table>
                </div>
                <div class="layui-card-body ">
                    <div class="page">
                        {$info|raw}
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script>
    /*日期区间*/
    common.setDate();
    /*全选*/
    common.selectCheckbox('checkbox','id[]');
    /*批量删除*/
    function dataDelAll() {
        //获取checkbox值
        var ids = common.getCheckboxVal();
        if(ids.length < 1){
            layer.msg('请选择需要操作的数据！',{time:1500, icon:5});
            return false;
        }
        layer.confirm('确认要删除选中的数据吗？',function(){
            var index = layer.load();
            $.ajax({
                type: 'POST',
                url: "{:url('Log/logDelAll')}",
                data: {ids:ids},
                dataType:'json',
                success:function(data){
                    if(data.status === 1){
                        layer.msg(data.info,{time:1500, icon:6},function(){
                            window.location.reload();
                        });
                    }else{
                        layer.msg(data.info,{time:1500, icon:5});
                    }
                    layer.close(index);
                },
                error:function(){
                    console.log(data.msg);
                    layer.msg("不好意思，出现了一点问题", {icon: 5});
                }
            });
        });
    }
    /*数据导出*/
    function dataExport(){
        layer.confirm('确认导出筛选的数据吗？',function(){
            //数据
            var info = {
                start: $('#start').val(),
                end: $('#end').val()
            };
            //导出
            var url = "{:url('Log/logExport')}";
            var unlink = "{:url('Login/unlinkFile')}";
            common.dataExport(info,url,unlink);
        });
    }
</script>
</html>